# Maintainer: Levente Polyak <levente[at]leventepolyak[dot]net>
# Contributor: s1gma <s1gma@mindslicer.com>

pkgname=ropgadget
_pkgname=ROPgadget
pkgver=7.1
pkgrel=2
pkgdesc='Search gadgets in binaries to facilitate ROP exploitation for several file formats and architectures'
url='http://www.shell-storm.org/project/ROPgadget'
arch=('any')
license=('BSD')
depends=('python' 'python-capstone')
makedepends=('python-setuptools' 'python-build' 'python-installer' 'python-wheel')
source=(https://github.com/JonathanSalwan/${_pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('f86956108ba5f131a609026087d4d952cb106ed03e72b04844ae551bdf5902ff70b917bc7c2bcd256591142d4f03e3aef0ceca7ad0d325fb5663f892e27b4b70')
b2sums=('dc06e99347987d9eb8b346a6a55599013b7d90b996cbd59f27721f26ce6e59a1ead7c0e3824fdb4fa4d215256d6ad378b2e6eec210561a217b2fa65b2efda169')

prepare() {
  cd ${_pkgname}-${pkgver}
  sed 's|python2|python|g' -i ropgadget/**/*.py ropgadget/*/*/*.py
}

build() {
  cd ${_pkgname}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  cd ${_pkgname}-${pkgver}
  ./ROPgadget.py --binary ./test-suite-binaries/elf-Linux-x86 --string "main"
}

package() {
  cd ${_pkgname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE_BSD.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim:set ts=2 sw=2 et:
